package com.wzy.vx.dataobject;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.wzy.vx.Utils.EnumUtil;
import com.wzy.vx.enums.ProductEnum;
import com.wzy.vx.enums.ProductStatusEnum;
import lombok.Data;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.UpdateTimestamp;

import javax.persistence.Entity;
import javax.persistence.Id;
import java.math.BigDecimal;
import java.util.Date;

/**
 * @ProjectName: vx
 * @Package: com.wzy.vx.dataobject
 * @ClassName: ProductInfo
 * @Author: Administrator
 * @Description: ${description}
 * @Date: 2019/3/12 11:40
 * @Version: 1.0
 */
@Entity
@Data
@DynamicUpdate
public class ProductInfo {
    @Id
    private String productId;

    //  product_name VARCHAR (64) NOT NULL COMMENT '商品名称',
    private String productName;

    //    product_price DECIMAL (8, 2) NOT NULL COMMENT '单价',
    private BigDecimal productPrice;

    //    product_stock INT NOT NULL COMMENT '库存',
    private Integer  productStock;

    //    product_description VARCHAR (64) COMMENT '描述',
    private String  productDescription;

    //    product_icon VARCHAR (512) COMMENT '小图片',
    private String productIcon;

    //    product_status
    private Integer productStatus = ProductStatusEnum.UP.getCode();



    //    category_type INT NOT NULL COMMENT '类目编号'0 正常 1下架,
    private Integer categoryType;

    @JsonFormat(pattern="yyyy-MM-dd  HH:mm:ss" ,  timezone="GMT+8")
    private Date categoryTime;

    @JsonFormat(pattern="yyyy-MM-dd  HH:mm:ss" ,  timezone="GMT+8")
    private Date updateTime;

    @JsonIgnore
    public ProductStatusEnum getProductStatusEnum(){
        return EnumUtil.getByCode(productStatus,ProductStatusEnum.class);
    }

    public Date getCategoryTime() {
        return categoryTime;
    }

    public void setCategoryTime(Date categoryTime) {
        this.categoryTime = categoryTime;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }



    public String getProductId() {
        return productId;
    }

    public void setProductId(String productId) {
        this.productId = productId;
    }

    public String getProductName() {
        return productName;
    }

    public void setProductName(String productName) {
        this.productName = productName;
    }

    public BigDecimal getProductPrice() {
        return productPrice;
    }

    public void setProductPrice(BigDecimal productPrice) {
        this.productPrice = productPrice;
    }

    public Integer getProductStock() {
        return productStock;
    }

    public void setProductStock(Integer productStock) {
        this.productStock = productStock;
    }

    public String getProductDescription() {
        return productDescription;
    }

    public void setProductDescription(String productDescription) {
        this.productDescription = productDescription;
    }

    public String getProductIcon() {
        return productIcon;
    }

    public void setProductIcon(String productIcon) {
        this.productIcon = productIcon;
    }

    public Integer getProductStatus() {
        return productStatus;
    }

    public void setProductStatus(Integer productStatus) {
        this.productStatus = productStatus;
    }

    public Integer getCategoryType() {
        return categoryType;
    }

    public void setCategoryType(Integer categoryType) {
        this.categoryType = categoryType;
    }

    public ProductInfo() {
    }
}
